<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  11111111
  <script>
    function fn() {
      console.log('JavaScript');
       document.writeln("aaaaaaaaaaa")
    }
    // 设置定时器时，保存定时器id
    var timer = setTimeout(function(){
       document.writeln("bbbbb")
    }, 2000);
    // 清除定时器时，传入要清楚的定时器id
     clearTimeout(timer);
  </script>
</body>
</html>